function go(){for(var A=0;A<items.length;A++){lines[A]=item_to_line(items[A]);items.shift()}timer=setInterval("addaline(true)",scrollDelay);
timer2=setTimeout("update()",updateDelay)}function setCheck(){spyshow=showitems*16+showdiggs*8+showburies*4+showcomments*2+pause;
write_tabs();write_checks();update_all()}function write_checks(){var A=$("spy-items");var D=$("spy-dugg");
var C=$("spy-buried");var B=$("spy-comments");if(showitems+showdiggs+showburies+showcomments==1){if(A.checked){A.disabled=true
}else{if(D.checked){D.disabled=true}else{if(C.checked){C.disabled=true}else{if(B.checked){B.disabled=true
}}}}}else{if(A.disabled){A.disabled=false}else{if(D.disabled){D.disabled=false}else{if(C.disabled){C.disabled=false
}else{if(B.disabled){B.disabled=false}}}}}}function write_tabs(){var A=$("checkboxes");if(spyshow!=30){if(showtop==2){A.innerHTML='<li><a href="/spy/front"?spyshow='+spyshow+'">Only Popular</a></li><li><a href="/spy/queue"?spyshow='+spyshow+'">Only Upcoming</a></li><li class="active"><span>All Stories</span></li>'
}else{if(showtop==1){A.innerHTML='<li class="active"><span>Only Popular</span></li><li><a href="/spy/queue"?spyshow='+spyshow+'">Only Upcoming</a></li><li><a href="/spy?spyshow='+spyshow+'">All Stories</a></li>'
}else{A.innerHTML='<li><a href="/spy/queue?spyshow='+spyshow+'">Only Popular</a></li><li class="active"><span>Only Upcoming</span></li><li><a href="/spy?spyshow='+spyshow+'">All Stories</a></li>'
}}}else{if(showtop==2){A.innerHTML='<li><a href="/spy/front">Only Popular</a></li><li><a href="/spy/queue">Only Upcoming</a></li><li class="active"><span>All Stories</span></li>'
}else{if(showtop==1){A.innerHTML='<li class="active"><span>Only Popular</span></li><li><a href="/spy/queue">Only Upcoming</a></li><li><a href="/spy">All Stories</a></li>'
}else{A.innerHTML='<li><a href="/spy/queue">Only Popular</a></li><li class="active"><span>Only Upcoming</span></li><li><a href="/spy">All Stories</a></li>'
}}}}function write_pause(){if(pause==0){document.getElementById("pause-play-toggle").innerHTML='<span class="spy-play"><strong>Play</strong></span><a href="#" onclick="togglepause()" class="spy-pause">Pause</a></span>'
}else{document.getElementById("pause-play-toggle").innerHTML='<a href="#" class="spy-play" onclick="togglepause()"><strong>Play</strong></a><span class="spy-pause"><strong title="Pause the display of new items.">Pause</strong></span>'
}}function update_all(){var A;A=0;while(items.length){items.shift()}while(lines.length){lines.shift()
}update_no_timestamp()}function item_to_line(A){var C="";var B="";if(A.type!="report"){if(A.userimage==""){B='<img src="/img/uds.png" width="14" height="14" alt="'+A.uid+'">'
}else{B='<img src="'+A.userimage+'" width="14" height="14" alt="'+A.uid+'">'}}if(A.type=="report"){C='<a href="'+A.plk+'" class="spy-actions"><img src="/img/spy-bury.gif" width="14" height="14" alt="buried" title="buried story"></a>'
}else{if(A.type=="comment"){C='<a href="'+A.plk+'" class="spy-actions"><img src="/img/spy-comment.gif" width="14" height="14" alt="comment" title="comment"></a>'
}else{if(A.type=="item"){C='<a href="'+A.plk+'" class="spy-actions"><img src="/img/spy-story.gif" width="14" height="14" alt="story" title="story"></a>'
}else{C='<a href="'+A.plk+'" class="spy-actions"><img src="/img/spy-digg.gif" width="14" height="14" alt="dugg" title="dugg story"></a>'
}}}C+='<a href="'+A.plk+'" class="spy-diggcount">+'+A.dig_count+'</a><a href="'+A.plk+'" class="spy-url"><strong>'+abbrev(A.title,50)+"</strong> <span>via "+hostname(A.url)+'</span></a><a href="'+A.plk+'" class="spy-location">'+A.area+"</a>";
if(A.type=="report"){C+='<a href="'+A.plk+'" class="spy-buried">['+A.reason+"]</a>"}else{C+='<a href="/users/'+A.uid+'" class="spy-user">'+B+" "+A.uid+"</a>"
}return C}function dataReceived(xh){var items=new Array();isBusy=false;if(xh.responseText.length>2){eval("items = ("+xh.responseText+")");
if(items.length){for(i=0;i<items.length;i++){if(items[i].timestamp>timestamp){timestamp=items[i].timestamp
}for(j=lines.length;j<lines.length+items.length;j++){i=j-lines.length;var image="";lines[j]=item_to_line(items[i]);
items.shift()}if(lines.length>0&&Math.round(updateDelay/(lines.length))>2000){scrollDelay=Math.round(20000/(lines.length));
if(!pause){clearInterval(timer);timer=setInterval("addaline(true)",scrollDelay)}}else{scrollDelay=2000;
if(!pause){clearInterval(timer);timer=setInterval("addaline(true)",scrollDelay)}}}}}if(!pause){clearTimeout(timer2);
timer2=setTimeout("update()",updateDelay)}}spyhttp=null;function update(){if(isBusy){return }isBusy=true;
spyhttp=new Ajax.Request("/spy_update",{method:"get",parameters:"timestamp="+timestamp+"&showtop="+showtop+"&showitems="+showitems+"&showdiggs="+showdiggs+"&showburies="+showburies+"&showcomments="+showcomments+"&showtop="+showtop+"&maxitems="+(30-items.length),onSuccess:dataReceived});
return false}function update_no_timestamp(){if(isBusy&&spyhttp){spyhttp.options.onSuccess=function(){};
spyhttp.transport.abort()}clearTimeout(timer2);isBusy=true;spyhttp=new Ajax.Request("/spy_update",{method:"get",parameters:"timestamp=0&showtop="+showtop+"&showitems="+showitems+"&showdiggs="+showdiggs+"&showburies="+showburies+"&showcomments="+showcomments+"&showtop="+showtop+"&maxitems="+(30-items.length),onSuccess:fullPageReceived});
return false}function togglepause(){pause=!pause;if(pause==1){clearInterval(timer);clearTimeout(timer2);
while(items.length){items.shift()}while(lines.length){lines.shift()}}else{update();timer=setInterval("addaline(true)",scrollDelay);
timer2=setTimeout("update()",updateDelay)}write_pause()}function toggleitems(){if(showitems==1){showitems=0
}else{showitems=1}setCheck()}function togglediggs(){if(showdiggs==1){showdiggs=0}else{showdiggs=1}setCheck()
}function toggleburies(){if(showburies==1){showburies=0}else{showburies=1}setCheck()}function togglecomments(){if(showcomments==1){showcomments=0
}else{showcomments=1}setCheck()}function hostname(A){var C=new RegExp(/^(ftp|http|file):\/\/([^\/]+)(\/.*)?(\/.*)/);
var B=C.exec(A);if(B){return(B[1]+"://"+B[2])}else{return A}}function abbrev(A,B){if(!A){return("")}else{if(A.length<=B){return(A)
}else{return(A.substr(0,B)+"...")}}}function addaline(H){var B=navigator.appName.indexOf("Microsoft")!=-1;
var G=navigator.userAgent.indexOf("Safari")!=-1;var A=navigator.userAgent.indexOf("Opera")!=-1;d=new Date();
if(lines.length){if(B||G||A){var F=lines.shift();if(F.length){currentline++;var D=$("spy");var J=D.getElementsByTagName("div");
var C=J.length;for(var E=C-1;E>1;E--){J[E].innerHTML=J[E-1].innerHTML}var I=$("active-row");if(B){H=0
}if(H){J[1].style.display="none";J[1].innerHTML=F;$j(I).fadeIn()}else{J[1].innerHTML=F}}}else{var F=document.createElement("div");
F.setAttribute("class","spy-story");F.innerHTML=lines.shift();currentline++;var D=$("spy");var J=D.getElementsByTagName("div");
var C=J.length;if(H){oldItem=$("active-row");F.style.display="none";D.insertBefore(F,oldItem);$j(F).fadeIn();
F.setAttribute("id","active-row");if(oldItem){oldItem.removeAttribute("id")}}else{oldItem=$("active-row");
D.insertBefore(F,oldItem);F.setAttribute("id","active-row");oldItem.setAttribute("id","")}D.removeChild(J[J.length-1]);
for(E=0;E<5;E++){labelnum=5-E;J[J.length-E-1].setAttribute("class","spy-story class-final-"+labelnum)
}}}};